﻿/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using VMuktiAPI;

namespace VMukti.Presentation.Controls
{
    /// <summary>
    /// Interaction logic for CtlPBX.xaml
    /// </summary>
    public partial class CtlPBX : UserControl,IDisposable
    {
        VMukti.Bussiness.PBXConfiguration.PBXConfiguration PBXConfig = null;
        public CtlPBX()
        {
            try
            {
                InitializeComponent();
                PBXConfig = new VMukti.Bussiness.PBXConfiguration.PBXConfiguration();
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "CtlPBX()--:--CtlPBX.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtUserName_M.Text != "" && txtPassword_M.Password != "" && txtDirname_M.Text != "")
                {
                    PBXConfig.FncPBXBusinessInsertCredential(txtUserName_M.Text, txtPassword_M.Password, txtDirname_M.Text);
                    txtUserName_M.Text = "";
                    txtPassword_M.Password = "";
                    txtDirname_M.Text = "";
                    MessageBox.Show("Saved successfully");
                }
                else
                {
                    MessageBox.Show("Fill Up All Information");
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "btnSubmit_Click()--:--CtlPBX.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                txtUserName_M.Text = "";
                txtPassword_M.Password = "";
                txtDirname_M.Text = "";
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "btnCancel_Click()--:--CtlPBX.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);

            }
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (PBXConfig != null)
            {
                PBXConfig = null;
            }
        }

        #endregion

        ~CtlPBX()
        {
            Dispose();
        }

    }
}
